package ThreadDemo;

public class synchronizedDemo3 {
    public static void main(String[] args) {
        Boo b = new Boo();
        Thread t = new Thread() {
            @Override
            public void run() {
                Boo.dosome();
            }
        };
        Thread t1 = new Thread() {
            @Override
            public void run() {
                Boo.dosome();
            }
        };
        t.start();
        t1.start();

    }
}

class Boo {
    public synchronized static void dosome() {
        Thread t = Thread.currentThread();
        try {
            synchronized (Boo.class) {
                System.out.println(t.getName() + ":正在执行dosome方法");
                Thread.sleep(1000);
                System.out.println(t.getName() + ":执行dosome方法结束！");
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
